package com.igeek.shop.service.gouwuche;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.igeek.shop.dao.BaseDao;
import com.igeek.shop.entity.Area;


/**
 * 实现三级联动地址添加
 * @author student
 *
 */
public class LinkageService {

	public static void getJson(Object[] params, HttpServletResponse resp) throws IOException {
		// TODO Auto-generated method stub
		String sql="select * from area where area_parent_id = ?";
		BaseDao<Area> dao = new BaseDao<Area>();
		Object list = dao.getList(sql, params, new Area());
		List<Area> areaList = (List<Area>)list;
		ObjectMapper mapper = new ObjectMapper();
		String json = null;
		
		try {
			json = mapper.writeValueAsString(areaList);
			resp.setContentType("text/html;charset=utf-8");
			resp.getWriter().write(json);
		} catch (JsonProcessingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
